<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ include file="/common/meta.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>灯灯网</title>
<link href="${ctx}/css/css.css" rel="stylesheet" type="text/css" />
<script>
	var fl=false;
	function changname(name){
		if(name.length==0){
			document.getElementById("name_msg").innerHTML="用户名不能为空！";
			return false;
			}
		if(isEmail(name)==false){
			document.getElementById("name_msg").innerHTML="邮箱格式不正确！";
			return false;
			}
		$.post("${ctx}/UserManager/user!isName.action",{"user.email":name},isname,"json");
		}

	function isname(obj){
		var flag=obj.flag;
		if(flag==true){
			document.getElementById("name_msg").innerHTML="该邮箱以被使用！";
			fl=false;
			}else{
				fl=true;
				document.getElementById("name_msg").innerHTML="恭喜您用户名可以使用！";
				}
		}

	function checkpwd(){
		var name=document.getElementById("username").value;
		var pwd=document.getElementById("pwd").value;
		var pwd1=document.getElementById("pwd1").value;

		if(name.length==0){
			document.getElementById("name_msg").innerHTML="用户名不能为空！";
			return false;
			}
		
		if(pwd.length==0){
			document.getElementById("pwd_msg").innerHTML="请输入密码！";
		    return false;
		}
		if(pwd1.length==0){
			document.getElementById("pwd1_msg").innerHTML="请再次输入密码！";
			return false;
			}
		if(!(pwd==pwd1)){
			document.getElementById("pwd1_msg").innerHTML="您两次输入的密码不正确！";
			return false;
			}
		if(fl==true){
			return true;
			}
		return false;
	}

	function isEmail(str){
		var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;

		if(myReg.test(str)){ 
			return true;
			}
		return false;

		}
</script>
</head>
<body>
<div align="center" style="background:url(images/bg.jpg);">
  <div class="main" align="center">
    <div class="table">
    <form action="${ctx}/UserManager/user!add.action" id="myfrom" method="post" onsubmit="return checkpwd();">
	  <table  border="0" cellspacing="8" cellpadding="0">
	  <tr>
	    <td style="color:#3686DF;">注册新账号：</td>	
	    <td><input id="username" name="user.email" class="input" onblur="changname(this.value);" /></td>
	    <td><input type="password" id="pwd" name="user.password" maxlength="20" class="input"/></td>
	    <td><input type="password" id="pwd1" name="password" maxlength="20"  class="input"/></td>
	    <td>
	    <input type="image" src="${ctx}/images/register.jpg"/>
	   	<a href="${ctx}/login.jsp"><img src="${ctx}/images/login.jpg" alt="登陆" /></a>
	  
	    </td>
	  </tr>
	  <tr>
	  	<td></td>
	  	<td style="color:#3686DF;"><span id="name_msg"></span></td>
	  	<td style="color:#3686DF;"><span id="pwd_msg"></span></td>
	  	<td style="color:#3686DF;"><span id="pwd1_msg"></span></td>
	  	<td></td>
	  </tr>
	</table>
</form>
  </div>
    <div class="foot">灯灯网版权所有 京ICP备***号 关于灯灯 联系我们 招贤纳士 服务条款 隐私政策网</div>
  </div>
  
</div>
</body>
</html>
